package com.by.component.importrecord.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum ImportProcessResultEnum {

    WAIT_PROCESS(0, "待处理"),
    PROCESSING(1, "处理中"),
    SUCCESS(2, "成功"),
    FAIL(3, "失败"),
    ;

    private Integer code;
    private String desc;

    private static final Map<Integer, ImportProcessResultEnum> MAP = Arrays.stream(ImportProcessResultEnum.values())
            .collect(Collectors.toMap(ImportProcessResultEnum::getCode, Function.identity()));

    public static ImportProcessResultEnum resolve(Integer code) {
        return MAP.get(code);
    }

}
